package com.xyz.business.service.impl;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.xyz.constant.XYZConstant;
import com.xyz.util.date.DateStyle;
import com.xyz.util.date.DateUtil;

/**
 * @author xyzjh
 * 
 */
public class ReportHelper {

	private static final SimpleDateFormat YYYY = new SimpleDateFormat("yyyy");
	/**
	 * 报告类型
	 */
	private static final Map<Integer, String> rtpTpeMap = new HashMap<Integer, String>(
			16);
	/**
	 * 是否协议
	 */
	private static final Map<Integer, String> agreeMap = new HashMap<Integer, String>(
			16);

	/**
	 * 税收类型
	 */
	private static final Map<Integer, String> taxTpeMap = new HashMap<Integer, String>(
			16);

	/**
	 * 企业性质
	 */
	private static final Map<String, String> natureMap = new HashMap<String, String>(
			16);
	/**
	 * 结算方式
	 */
	private static final Map<Integer, String> clearwayMap = new HashMap<Integer, String>(
			16);
	/**
	 * 是否结算
	 */
	private static final Map<Integer, String> isclearMap = new HashMap<Integer, String>(
			16);
	
	/**
	 * 货币类型
	 */
	private static final Map<String, String> currencyTypeMap = new HashMap<String, String>(
			16);
	
	/**
	 * 统计表表头
	 */
	private static final List<String> collectTitle = new ArrayList<String>(32);

	/**
	 * 采集表表头
	 */
	private static final List<String> staticTitle = new ArrayList<String>(32);
	static {
		rtpTpeMap.put(1, "广安（审）");
		rtpTpeMap.put(2, "广安（验）");
		rtpTpeMap.put(3, "广君（税）");
		rtpTpeMap.put(4, "广君（查）");

		agreeMap.put(1, "是");
		agreeMap.put(2, "否");

		taxTpeMap.put(1, "国税");
		taxTpeMap.put(2, "地税");

		natureMap.put("1", "个人独资");
		natureMap.put("2", "股份合作制企业");
		natureMap.put("3", "国有企业");
		natureMap.put("4", "个人合伙企业");
		natureMap.put("5", "集体所有制企业");
		natureMap.put("6", "事业单位");
		natureMap.put("7", "外国企业常驻代表机构");
		natureMap.put("8", "外商投资企业");
		natureMap.put("9", "有限责任公司");
		natureMap.put("10", "分支机构");
		natureMap.put("11", "个体工商户");
		natureMap.put("12", "公募");
		natureMap.put("13", "民办非企业单位");
		natureMap.put("14", "全民所有制");
		natureMap.put("15", "社会团体");

		clearwayMap.put(1, "银行");
		clearwayMap.put(2, "现金");

		isclearMap.put(1, "是");
		isclearMap.put(2, "否");

		collectTitle.add("报告年度");
		collectTitle.add("报告字号");
		collectTitle.add("报告单号");
		collectTitle.add("企业名称");
		collectTitle.add("协议金额(元)");
		collectTitle.add("联系人");
		collectTitle.add("项目负责人");
		collectTitle.add("注会计师一");
		collectTitle.add("注会计师二");
		collectTitle.add("助理人员1");
		collectTitle.add("助理人员2");
		collectTitle.add("助理人员3");
		collectTitle.add("开票日期");
		collectTitle.add("收款金额(元)");
		collectTitle.add("收款日期");
		collectTitle.add("结算方式");

		staticTitle.add("编号");
		staticTitle.add("报告年度");
		staticTitle.add("报告字号");
		staticTitle.add("报告单号");
		staticTitle.add("企业名称");
		staticTitle.add("地址");
		staticTitle.add("开业时间");
		staticTitle.add("经营范围");
		staticTitle.add("营业执照号");
		staticTitle.add("企业性质");
		staticTitle.add("法人名称");
		staticTitle.add("注册资本(万元)");
		staticTitle.add("国税地税");
		staticTitle.add("国税登记证号");
		staticTitle.add("地税登记证号");
		
		
		
		currencyTypeMap.put("CNY", "人民币");
		currencyTypeMap.put("HKD", "港元");
		currencyTypeMap.put("TWD", "台币");
		currencyTypeMap.put("EUR", "欧元");
		currencyTypeMap.put("USD", "美元");
		currencyTypeMap.put("GBP", "英镑");
		currencyTypeMap.put("AUD", "澳元");
		currencyTypeMap.put("KRW", "韩元");
		currencyTypeMap.put("JPY", "日元");

	}

	public static Map<Integer, String> getRtpTpeMap() {
		return rtpTpeMap;
	}

	/**
	 * 根据报告类型id转换成报告类型名称 1：广安（审） 2：广安（验） 3：广君（税） 4：广君（查）
	 * 
	 * @param rptTpeId
	 * @return 报告类型名称
	 */
	public static String getRptTyeNameByRptTpe(int rptTpeId) {
		// String rptTyeName = XYZConstant.EMPTY;

		return rtpTpeMap.get(rptTpeId);
		// switch (rptTpeId) {
		// case 1:
		// rptTyeName = "广安（审）";
		// break;
		// case 2:
		// rptTyeName = "广安（验）";
		// break;
		// case 3:
		// rptTyeName = "广君（税）";
		// break;
		// case 4:
		// rptTyeName = "广君（查）";
		// break;
		// default:
		// break;
		// }
		//
		// return rptTyeName;
	}

	/**
	 * 由报告类型id获取公司名称： 1、2：广州安立信会计事务所有限公司 3、4：广州君联税务师事务所有限公司
	 * 
	 * @param rptTpeId
	 * @return
	 */
	public static String getCompanyByRptTpe(int rptTpeId) {
		String company = XYZConstant.EMPTY;
		switch (rptTpeId) {
		case 1:
		case 2:
			company = "广州安立信会计事务所有限公司";
			break;
		case 3:
		case 4:
			company = "广州君联税务师事务所有限公司";
			break;
		default:
			break;
		}

		return company;
	}

	/**
	 * 由报告类型id获取业务内容 1、2：验资 3、4：汇算清缴
	 * 
	 * @param rptTpeId
	 * @return 业务内容
	 */
	public static String getBussContentByRptTpe(int rptTpeId) {
		String busscontent = XYZConstant.EMPTY;
		switch (rptTpeId) {
		case 1:
		case 2:
			busscontent = "验资";
			break;
		case 3:
		case 4:
			busscontent = "汇缴清算";
			break;
		default:
			break;
		}

		return busscontent;
	}

	public static String getYear(Date year) {
		String dateString = XYZConstant.EMPTY;
		if (null != year) {
			return YYYY.format(year);
		}
		return dateString;

	}

	public static Map<Integer, String> getAgreeMap() {
		return agreeMap;
	}

	public static Map<Integer, String> getTaxTpeMap() {
		return taxTpeMap;
	}

	public static Map<String, String> getNatureMap() {
		return natureMap;
	}

	public static Map<Integer, String> getClearWayMap() {
		return clearwayMap;
	}

	public static Map<Integer, String> getIsclearMap() {
		return isclearMap;
	}

	public static void baseMethod(HttpServletRequest request) {
		// 报告类型
		Map<Integer, String> rptpemap = ReportHelper.getRtpTpeMap();
		request.setAttribute("rptpemap", rptpemap);
		request.setAttribute("rptpe", 0);
		// 是否协议书
		Map<Integer, String> agreeMap = ReportHelper.getAgreeMap();
		request.setAttribute("agreeMap", agreeMap);
		request.setAttribute("isagree", 0);
		// 国税性质
		Map<Integer, String> taxTpeMap = ReportHelper.getTaxTpeMap();
		request.setAttribute("taxTpeMap", taxTpeMap);
		request.setAttribute("taxType", 0);
		// 企业性质
		Map<String, String> natureMap = ReportHelper.getNatureMap();
		request.setAttribute("natureMap", natureMap);
		request.setAttribute("nature", 0);

		// 结算方式
		Map<Integer, String> clearwayMap = ReportHelper.getClearWayMap();
		request.setAttribute("clearwayMap", clearwayMap);
		request.setAttribute("clearway", 0);

		// 是否结算
		Map<Integer, String> isclearMap = ReportHelper.getIsclearMap();
		request.setAttribute("isclearMap", isclearMap);
		request.setAttribute("isclear", 0);
		
		// 企业性质
		Map<String, String> currcyTypeMap = ReportHelper.getCrrcyTypeMap();
		request.setAttribute("currcyTypeMap", currcyTypeMap);
		request.setAttribute("currencytype", 0);

	}

	/**
	 * 资料统计表名称： 数据统计表20111020-10120312
	 * 
	 * @param beginTime
	 * @param endTime
	 * @return
	 */
	public static String getSataicFileName(Date beginTime, Date endTime) {
		String begin = "";
		String end = "";
		if (null == beginTime) {
			begin = "20010101";
		} else {
			begin = DateUtil.DateToString(beginTime, DateStyle.YYYYMMDD);
		}

		if (null == endTime) {
			end = "20991230";
		} else {
			end = DateUtil.DateToString(beginTime, DateStyle.YYYYMMDD);
		}
		StringBuffer stringBuffer = new StringBuffer(64);
		stringBuffer.append("资料统计表").append(begin).append("-").append(end)
				.toString();
		return stringBuffer.toString();
	}

	/**
	 * 数据采集表名称：数据采集表年份+报告号 数据采集表+报告号
	 * 
	 * @param beginTime
	 * @param endTime
	 * @return
	 */
	public static String getCollectFileName(String rtpno) {
		return new StringBuffer(32).append("数据采集表").append(rtpno).toString();
	}

	public static SimpleDateFormat getYyyy() {
		return YYYY;
	}

	public static Map<Integer, String> getRtptpemap() {
		return rtpTpeMap;
	}

	public static Map<Integer, String> getAgreemap() {
		return agreeMap;
	}

	public static Map<Integer, String> getTaxtpemap() {
		return taxTpeMap;
	}

	public static Map<String, String> getNaturemap() {
		return natureMap;
	}

	public static Map<Integer, String> getClearwaymap() {
		return clearwayMap;
	}

	public static Map<Integer, String> getIsclearmap() {
		return isclearMap;
	}

	public static List<String> getCollecttitle() {
		return collectTitle;
	}

	public static List<String> getStatictitle() {
		return staticTitle;
	}
	
	public static  Map<String, String> getCrrcyTypeMap() {
		return currencyTypeMap;
	}
}
